package cn.bdqn.util;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by Administrator on 2018/8/17.
 * Swagger API文档生成工具初始化配置信息
 */

@Configuration// 写了applicationContext-mybatis.xml
@ComponentScan(basePackages="cn.bdqn.controller") // <context-ComponentScan basepackage="xxx.xx.x.xx">
@EnableSwagger2//启动swaggerapi生成
public class SwaggerConfig extends WebMvcConfigurationSupport{
    @Bean// <bean id="apiGen" class="Docket"/>

    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();

    }
    /**
     * 创建该Api的基本信息（这些基本信息会展现在文档页面中）
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("爱旅行-用户认证模块API")
                .termsOfServiceUrl("")
                .contact("爱旅行项目组")
                .version("1.0")
                .build();
    }

}